package com.sugon.modules.analyse.model.chart;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.sugon.modules.analyse.consts.KpiTarget;
import com.sugon.modules.analyse.consts.MoldKpiTarget;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author ： YuXD
 * @description： KPI维度柱状图数据VO
 * @date ： 2020-11-15 11:47
 * @version: 1.0
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
public class KpiTargetBarEchartOptionDataVO implements Serializable {

    /**
     * 维度名称
     */
    private String targetLabel;

    /**
     * KPI维度值
     */
    private String targetValue;

    /**
     * 柱状图Series数据
     */
    private List<Double> seriesData;

    /**
     * Y轴单位，默认为%
     */
    private String unit = "%";

    /**
     * Y轴最大值，默认为100
     */
    private Integer max = 100;

    public KpiTargetBarEchartOptionDataVO() {
        this.seriesData = new ArrayList<>();
    }

    public KpiTargetBarEchartOptionDataVO(String unit, Integer max) {
        this.unit = unit;
        this.max = max;
    }

    public void setKpiTarget(KpiTarget kpiTarget) {
        this.targetLabel = kpiTarget.getLabel();
        this.targetValue = kpiTarget.getValue();
    }

    public void setMoldKpiTarget(MoldKpiTarget kpiTarget) {
        this.targetLabel = kpiTarget.getLabel();
        this.targetValue = kpiTarget.getValue();
    }

    public void add(Double seriesData) {
        if (this.seriesData == null) {
            this.seriesData = new ArrayList<>();
        }
        this.seriesData.add(seriesData);
    }

}
